using System;
using System.Collections.Generic;
using System.Text;

using Peradigm.Framework.Configuration;
using Peradigm.Framework.Configuration.Exceptions;
using Peradigm.Framework.Domain.Exceptions;

namespace Liberty.Application
{
    [Serializable]
    public abstract class AbstractController : Object
    {
        #region Constants
        private const string
            EXCEPTION_MSG = "ConnectionString key was not found in the config file.",
            CXN_STRING_KEY = "ConnectionString";
        #endregion

        #region Event Handlers
        #endregion

        #region Methods
        #endregion

        #region Properties
        public string ConnectionString
        {
            get
            {
                string cxnString = null;

                try
                {
                    cxnString = ApplicationConfiguration.Settings[CXN_STRING_KEY];
                }
                catch( Exception ex )
                {
                    throw new SettingIsNotAvailableException(
                        CXN_STRING_KEY,
                        String.Format( "{0}.  Inner Exception: {1}", EXCEPTION_MSG, ex.ToString() ),
                        Severity.Catastrophic
                        );
                }

                if( cxnString == null || cxnString.Length == 0 )
                {
                    throw new SettingIsNotAvailableException( EXCEPTION_MSG, Severity.Catastrophic );
                }

                return cxnString;
            }
        }
        #endregion

        #region Private Methods
        #endregion

        #region Private Properties
        #endregion

        #region Construction and Finalization
        public AbstractController()
        {
        }
        #endregion

        #region Data Elements
        #endregion
    }
}
